<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Overview | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ccr-overview.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ccr-overview.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ccr-overview.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ccr-overview.html" rel="nofollow" target="_blank">../en/ccr-overview.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="high-availability.html">Set up a cluster for high availability</a></span>
»
<span class="breadcrumb-link"><a href="xpack-ccr.html">Cross-cluster replication</a></span>
»
<span class="breadcrumb-node">Overview</span>
</div>
<div class="navheader">
<span class="prev">
<a href="xpack-ccr.html">« Cross-cluster replication</a>
</span>
<span class="next">
<a href="ccr-requirements.html">Requirements for leader indices »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ccr-overview"></a>Overview<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>Cross-cluster replication is done on an index-by-index basis. Replication is
configured at the index level. For each configured replication there is a
replication source index called the <em>leader index</em> and a replication target
index called the <em>follower index</em>.</p>
<p>Replication is active-passive. This means that while the leader index
can directly be written into, the follower index can not directly receive
writes.</p>
<p>Replication is pull-based. This means that replication is driven by the
follower index. This simplifies state management on the leader index and means
that cross-cluster replication does not interfere with indexing on the leader index.</p>
<p>In cross-cluster replication, the cluster performing this pull is known as the <em>local cluster</em>. The
cluster being replicated is known as the <em>remote cluster</em>.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_prerequisites_11"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Cross-cluster replication requires <a class="xref" href="modules-remote-clusters.html" title="Remote clusters">remote clusters</a>.
</li>
<li class="listitem">
The Elasticsearch version of the local cluster must be <span class="strong strong"><strong>the same as or newer</strong></span> than
the remote cluster. If newer, the versions must also be compatible as outlined
in the following matrix.
</li>
</ul>
</div>
<div class="informaltable">
<table border="1" cellpadding="4px">
<colgroup>
<col class="col_1">
<col class="col_2">
<col class="col_3">
<col class="col_4">
<col class="col_5">
<col class="col_6">
<col class="col_7">
<col class="col_8">
</colgroup>
<tbody>
<tr>
<td align="center" valign="top"><p>Compatibility</p></td>
<td align="center" valign="top"><p>5.0→5.5</p></td>
<td align="center" valign="top"><p>5.6</p></td>
<td align="center" valign="top"><p>6.0→6.6</p></td>
<td align="center" valign="top"><p>6.7</p></td>
<td align="center" valign="top"><p>6.8</p></td>
<td align="center" valign="top"><p>7.0</p></td>
<td align="center" valign="top"><p>7.1→7.x</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>5.0→5.5</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>5.6</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>6.0→6.6</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>6.7</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>No</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>6.8</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>7.0</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
</tr>
<tr>
<td align="center" valign="top"><p>7.1→7.x</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>No</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
<td align="center" valign="top"><p>Yes</p></td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_configuring_replication"></a>Configuring replication<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Replication can be configured in two ways:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Manually creating specific follower indices (in Kibana or by using the
<a href="ccr-put-follow.html" class="ulink" target="_top">create follower API</a>)
</li>
<li class="listitem">
Automatically creating follower indices from auto-follow patterns (in Kibana or
by using the <a href="ccr-put-auto-follow-pattern.html" class="ulink" target="_top">create auto-follow pattern API</a>)
</li>
</ul>
</div>
<p>For more information about managing cross-cluster replication in Kibana, see
<a href="https://www.elastic.co/guide/en/kibana/7.7/working-remote-clusters.html" class="ulink" target="_top">Working with remote clusters</a>.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>You must also <a class="xref" href="ccr-requirements.html" title="Requirements for leader indices">configure the leader index</a>.</p>
</div>
</div>
<p>When you initiate replication either manually or through an auto-follow pattern, the
follower index is created on the local cluster. Once the follower index is created,
the <a class="xref" href="remote-recovery.html" title="Remote recovery">remote recovery</a> process copies all of the Lucene segment
files from the remote cluster to the local cluster.</p>
<p>By default, if you initiate following manually (by using Kibana or the create follower API),
the recovery process is asynchronous in relationship to the
<a href="ccr-put-follow.html" class="ulink" target="_top">create follower request</a>. The request returns before
the <a class="xref" href="remote-recovery.html" title="Remote recovery">remote recovery</a> process completes. If you would like to wait on
the process to complete, you can use the <code class="literal">wait_for_active_shards</code> parameter.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_the_mechanics_of_replication"></a>The mechanics of replication<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>While replication is managed at the index level, replication is performed at the
shard level. When a follower index is created, it is automatically
configured to have an identical number of shards as the leader index. A follower
shard task in the follower index pulls from the corresponding leader shard in
the leader index by sending read requests for new operations. These read
requests can be served from any copy of the leader shard (primary or replicas).</p>
<p>For each read request sent by the follower shard task, if there are new
operations available on the leader shard, the leader shard responds with
operations limited by the read parameters that you established when you
configured the follower index. If there are no new operations available on the
leader shard, the leader shard waits up to a configured timeout for new
operations. If new operations occur within that timeout, the leader shard
immediately responds with those new operations. Otherwise, if the timeout
elapses, the leader shard replies that there are no new operations. The
follower shard task updates some statistics and immediately sends another read
request to the leader shard. This ensures that the network connections between
the remote cluster and the local cluster are continually being used so as to
avoid forceful termination by an external source (such as a firewall).</p>
<p>If a read request fails, the cause of the failure is inspected. If the
cause of the failure is deemed to be a failure that can be recovered from (for
example, a network failure), the follower shard task enters into a retry
loop. Otherwise, the follower shard task is paused and requires user
intervention before it can be resumed with the
<a href="ccr-post-resume-follow.html" class="ulink" target="_top">resume follower API</a>.</p>
<p>When operations are received by the follower shard task, they are placed in a
write buffer. The follower shard task manages this write buffer and submits
bulk write requests from this write buffer to the follower shard.  The write
buffer and these write requests are managed by the write parameters that you
established when you configured the follower index.  The write buffer serves as
back-pressure against read requests. If the write buffer exceeds its configured
limits, no additional read requests are sent by the follower shard task. The
follower shard task resumes sending read requests when the write buffer no
longer exceeds its configured limits.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>The intricacies of how operations are replicated from the leader are
governed by settings that you can configure when you create the follower index
in Kibana or by using the <a href="ccr-put-follow.html" class="ulink" target="_top">create follower API</a>.</p>
</div>
</div>
<p>Mapping updates applied to the leader index are automatically retrieved
as-needed by the follower index. It is not possible to manually modify the
mapping of a follower index.</p>
<p>Settings updates applied to the leader index that are needed by the follower
index are automatically retrieved as-needed by the follower index. Not all
settings updates are needed by the follower index. For example, changing the
number of replicas on the leader index is not replicated by the follower index.</p>
<p>Alias updates applied to the leader index are automatically retrieved by the
follower index. It is not possible to manually modify an alias of a follower
index.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>If you apply a non-dynamic settings change to the leader index that is
needed by the follower index, the follower index will go through a cycle of
closing itself, applying the settings update, and then re-opening itself. The
follower index will be unavailable for reads and not replicating writes
during this cycle.</p>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_inspecting_the_progress_of_replication"></a>Inspecting the progress of replication<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can inspect the progress of replication at the shard level with the
<a href="ccr-get-follow-stats.html" class="ulink" target="_top">get follower stats API</a>. This API gives you
insight into the read and writes managed by the follower shard task. It also
reports read exceptions that can be retried and fatal exceptions that require
user intervention.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_pausing_and_resuming_replication"></a>Pausing and resuming replication<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can pause replication with the
<a href="ccr-post-pause-follow.html" class="ulink" target="_top">pause follower API</a> and then later resume
replication with the <a href="ccr-post-resume-follow.html" class="ulink" target="_top">resume follower API</a>.
Using these APIs in tandem enables you to adjust the read and write parameters
on the follower shard task if your initial configuration is not suitable for
your use case.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_leader_index_retaining_operations_for_replication"></a>Leader index retaining operations for replication<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>If the follower is unable to replicate operations from a leader for a period of
time, the following process can fail due to the leader lacking a complete history
of operations necessary for replication.</p>
<p>Operations replicated to the follower are identified using a sequence number
generated when the operation was initially performed. Lucene segment files are
occasionally merged in order to optimize searches and save space. When these
merges occur, it is possible for operations associated with deleted or updated
documents to be pruned during the merge. When the follower requests the sequence
number for a pruned operation, the process will fail due to the operation missing
on the leader.</p>
<p>This scenario is not possible in an append-only workflow. As documents are never
deleted or updated, the underlying operation will not be pruned.</p>
<p>Elasticsearch attempts to mitigate this potential issue for update workflows using
a Lucene feature called soft deletes. When a document is updated or deleted, the
underlying operation is retained in the Lucene index for a period of time. This
period of time is governed by the <code class="literal">index.soft_deletes.retention_lease.period</code>
setting which can be <a class="xref" href="ccr-requirements.html" title="Requirements for leader indices">configured on the leader index</a>.</p>
<p>When a follower initiates the index following, it acquires a retention lease from
the leader. This informs the leader that it should not allow a soft delete to be
pruned until either the follower indicates that it has received the operation or
the lease expires. It is valuable to have monitoring in place to detect a follower
replication issue prior to the lease expiring so that the problem can be remedied
before the follower falls fatally behind.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_remedying_a_follower_that_has_fallen_behind"></a>Remedying a follower that has fallen behind<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>If a follower falls sufficiently behind a leader that it can no longer replicate
operations this can be detected in Kibana or by using the
<a href="ccr-get-follow-stats.html" class="ulink" target="_top">get follow stats API</a>. It will be reported as a
<code class="literal">indices[].fatal_exception</code>.</p>
<p>In order to restart the follower, you must pause the following process, close the
index, and the create follower index again. For example:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST /follower_index/_ccr/pause_follow

POST /follower_index/_close

PUT /follower_index/_ccr/follow?wait_for_active_shards=1
{
  "remote_cluster" : "remote_cluster",
  "leader_index" : "leader_index"
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1173.console"></div>
<p>Re-creating the follower index is a destructive action. All of the existing Lucene
segment files are deleted on the follower cluster. The
<a class="xref" href="remote-recovery.html" title="Remote recovery">remote recovery</a> process copies the Lucene segment
files from the leader again. After the follower index initializes, the
following process starts again.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_terminating_replication"></a>Terminating replication<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ccr/overview.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can terminate replication with the
<a href="ccr-post-unfollow.html" class="ulink" target="_top">unfollow API</a>. This API converts a follower index
to a regular (non-follower) index.</p>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="xpack-ccr.html">« Cross-cluster replication</a>
</span>
<span class="next">
<a href="ccr-requirements.html">Requirements for leader indices »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>